<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
    <!-- 前端创造一个json请求，后端用jackson接受 -->
    <input type="text" id="userId">
    <input type="text" id="classId">
    <input type="submit" value="提交" id="submit">

    <script>
        let userIdInput = document.querySelector('#userId');
        let classIdInput = document.querySelector('#classId');
        let button = document.querySelector('#submit');

        button.onclick = function() {
            $.ajax({
                type: 'post',
                url: 'postParameter',
                contentType: 'application/json',
                data: JSON.stringify({
                    userId: userIdInput.value,
                    classId: classIdInput.value
                }),
                success: function(body) {
                    console.log(body);
                }
            });
        }
    </script>
</body>
</html>